/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-16 16:05:00
 * @LastEditTime: 2021-08-16 16:05:27
 * @LastEditors: changqing
 * @Usage: 
 */
class MyIterator{
	constructor(arr) {
		this._arr = arr
		this._cursor = 0
	}
	next(){
		return this._cursor < this._arr.length?{value:this._arr[this._cursor++],done:false}:{done:true, value:void 0}
	}
	map(cb){
		const iterator = new MyIterator(this._arr)
		return {
			next:()=>{
					const {done, value} = iterator.next()
					return {
						done,
						value: done? void 0 : cb(value)
					}
				}
		}
	}
}
const iterator = new MyIterator([1,2,3]);
const newIterator = iterator.map(value => value + 3);

newIterator.next();
// { value: 4, done: false }
newIterator.next();
// { value: 5, done: false }
newIterator.next();
// { value: 6, done: false }